/*   1:    */ package tt.dz.web.controller.financial;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import java.text.DateFormat;
/*   5:    */ import java.text.SimpleDateFormat;
/*   6:    */ import java.util.Date;
/*   7:    */ import java.util.HashMap;
/*   8:    */ import java.util.LinkedHashMap;
/*   9:    */ import java.util.List;
/*  10:    */ import java.util.Map;
/*  11:    */ import javax.annotation.Resource;
/*  12:    */ import javax.servlet.http.HttpServletRequest;
/*  13:    */ import javax.servlet.http.HttpServletResponse;
/*  14:    */ import org.apache.commons.lang3.StringUtils;
/*  15:    */ import org.springframework.stereotype.Controller;
/*  16:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  17:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  18:    */ import tt.dz.biz.service.common.CommonService;
/*  19:    */ import tt.dz.biz.service.financial.MerchantReportService;
/*  20:    */ import tt.dz.common.ExcelUtill;
/*  21:    */ import tt.dz.common.JSONUtil;
/*  22:    */ import tt.dz.common.LogUtil;
/*  23:    */ import tt.dz.vo.BorrowLoanCheckVO;
/*  24:    */ import tt.dz.vo.MerchAccountDetailVO;
/*  25:    */ import tt.dz.vo.MerchantSubjectAccVO;
/*  26:    */ import tt.dz.vo.ResponseModle;
/*  27:    */ import tt.dz.vo.TranInfoVO;
/*  28:    */ 
/*  29:    */ @Controller
/*  30:    */ public class MerchantReportController
/*  31:    */ {
/*  32:    */   @Resource(name="merchantReportService")
/*  33:    */   private MerchantReportService merchantReportService;
/*  34:    */   @Resource(name="commonService")
/*  35:    */   private CommonService commonService;
/*  36:    */   
/*  37:    */   @RequestMapping(value={"/querymerchantDailyAccouting"}, produces={"application/json;charset=UTF-8"})
/*  38:    */   @ResponseBody
/*  39:    */   public String querymerchantDailyAccouting(HttpServletRequest request)
/*  40:    */   {
/*  41: 50 */     ResponseModle rs = new ResponseModle();
/*  42:    */     try
/*  43:    */     {
/*  44: 52 */       MerchAccountDetailVO merchAccountDetailVO = (MerchAccountDetailVO)JSONUtil.parseObjectAsDateFormat(request.getParameter("merchAccountDetailVO"), MerchAccountDetailVO.class);
/*  45: 53 */       List<MerchAccountDetailVO> dailyList = this.merchantReportService.querymerchantDailyAccouting(merchAccountDetailVO);
/*  46: 54 */       rs.setRequestStatus("success");
/*  47: 55 */       rs.setRequestResult(dailyList);
/*  48:    */     }
/*  49:    */     catch (Exception e)
/*  50:    */     {
/*  51: 57 */       LogUtil.error("查询日记账报表异常", e);
/*  52: 58 */       rs.setRequestStatus("error");
/*  53: 59 */       rs.setRequestResult("查询异常，请稍后再试。");
/*  54:    */     }
/*  55: 61 */     return JSON.toJSONString(rs);
/*  56:    */   }
/*  57:    */   
/*  58:    */   @RequestMapping(value={"/queryBorrowLoanCheck"}, produces={"application/json;charset=UTF-8"})
/*  59:    */   @ResponseBody
/*  60:    */   public String queryBorrowLoanCheck(HttpServletRequest request)
/*  61:    */   {
/*  62: 71 */     ResponseModle rs = new ResponseModle();
/*  63:    */     try
/*  64:    */     {
/*  65: 73 */       String start = request.getParameter("startDate");
/*  66: 74 */       String end = request.getParameter("endDate");
/*  67: 75 */       DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
/*  68: 76 */       Date startDate = null;
/*  69: 77 */       Date endDate = null;
/*  70: 78 */       if (StringUtils.isNotBlank(start)) {
/*  71: 79 */         startDate = df.parse(start);
/*  72:    */       }
/*  73: 81 */       if (StringUtils.isNotBlank(end)) {
/*  74: 82 */         endDate = df.parse(end);
/*  75:    */       }
/*  76: 84 */       List<BorrowLoanCheckVO> borrowLoanList = this.merchantReportService.queryBorrowLoanCheck(startDate, endDate);
/*  77: 85 */       LogUtil.debug("borrowLoanList================" + borrowLoanList);
/*  78: 86 */       rs.setRequestStatus("success");
/*  79: 87 */       rs.setRequestResult(borrowLoanList);
/*  80:    */     }
/*  81:    */     catch (Exception e)
/*  82:    */     {
/*  83: 89 */       LogUtil.error("查询借贷平衡异常", e);
/*  84: 90 */       rs.setRequestStatus("error");
/*  85: 91 */       rs.setRequestResult("查询借贷平衡异常，请稍后再试。");
/*  86:    */     }
/*  87: 93 */     return JSON.toJSONString(rs);
/*  88:    */   }
/*  89:    */   
/*  90:    */   @RequestMapping(value={"/queryChannelPayList"}, produces={"application/json;charset=UTF-8"})
/*  91:    */   @ResponseBody
/*  92:    */   public String queryChannelPayList(HttpServletRequest request)
/*  93:    */   {
/*  94:103 */     ResponseModle rs = new ResponseModle();
/*  95:    */     try
/*  96:    */     {
/*  97:105 */       String channelCode = request.getParameter("channelCode");
/*  98:106 */       String start = request.getParameter("startDate");
/*  99:107 */       String end = request.getParameter("endDate");
/* 100:108 */       DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
/* 101:109 */       Date startDate = null;
/* 102:110 */       Date endDate = null;
/* 103:111 */       if (StringUtils.isNotBlank(start)) {
/* 104:112 */         startDate = df.parse(start);
/* 105:    */       }
/* 106:114 */       if (StringUtils.isNotBlank(end)) {
/* 107:115 */         endDate = df.parse(end);
/* 108:    */       }
/* 109:117 */       List<TranInfoVO> tranInfoList = this.merchantReportService.queryChannelPayList(channelCode, startDate, endDate);
/* 110:118 */       rs.setRequestStatus("success");
/* 111:119 */       rs.setRequestResult(tranInfoList);
/* 112:    */     }
/* 113:    */     catch (Exception e)
/* 114:    */     {
/* 115:121 */       LogUtil.error("查询渠道交易明细异常", e);
/* 116:122 */       rs.setRequestStatus("error");
/* 117:123 */       rs.setRequestResult("查询渠道交易明细异常，请稍后再试。");
/* 118:    */     }
/* 119:125 */     return JSON.toJSONString(rs);
/* 120:    */   }
/* 121:    */   
/* 122:    */   @RequestMapping(value={"/queryBalanceOfPayments"}, produces={"application/json;charset=UTF-8"})
/* 123:    */   @ResponseBody
/* 124:    */   public String queryBalanceOfPayments(HttpServletRequest request)
/* 125:    */   {
/* 126:138 */     ResponseModle rs = new ResponseModle();
/* 127:    */     try
/* 128:    */     {
/* 129:140 */       String merchantCode = request.getParameter("merchantCode");
/* 130:141 */       String start = request.getParameter("startDate");
/* 131:142 */       String end = request.getParameter("endDate");
/* 132:143 */       DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
/* 133:144 */       Date startDate = null;
/* 134:145 */       Date endDate = null;
/* 135:146 */       if (StringUtils.isNotBlank(start)) {
/* 136:147 */         startDate = df.parse(start);
/* 137:    */       }
/* 138:149 */       if (StringUtils.isNotBlank(end)) {
/* 139:150 */         endDate = df.parse(end);
/* 140:    */       }
/* 141:152 */       List<Map<String, Object>> balanceList = this.merchantReportService.queryBalanceOfPayments(startDate, endDate, merchantCode);
/* 142:153 */       Map<String, Integer> totalMap = new HashMap();
/* 143:154 */       String tradNo = null;
/* 144:155 */       for (Map<String, Object> map : balanceList)
/* 145:    */       {
/* 146:156 */         tradNo = (String)map.get("tradeNo");
/* 147:157 */         if (totalMap.containsKey(tradNo))
/* 148:    */         {
/* 149:158 */           map.put("show", Boolean.valueOf(false));
/* 150:159 */           totalMap.put(tradNo, Integer.valueOf(((Integer)totalMap.get(tradNo)).intValue() + 1));
/* 151:    */         }
/* 152:    */         else
/* 153:    */         {
/* 154:161 */           map.put("show", Boolean.valueOf(true));
/* 155:162 */           totalMap.put(tradNo, Integer.valueOf(1));
/* 156:    */         }
/* 157:    */       }
/* 158:165 */       rs.setRequestStatus("success");
/* 159:166 */       Object rsMap = new HashMap();
/* 160:167 */       ((Map)rsMap).put("totalCount", totalMap);
/* 161:168 */       ((Map)rsMap).put("dataList", balanceList);
/* 162:169 */       rs.setRequestResult(rsMap);
/* 163:    */     }
/* 164:    */     catch (Exception e)
/* 165:    */     {
/* 166:171 */       LogUtil.error("按日查询收支明细异常", e);
/* 167:172 */       rs.setRequestStatus("error");
/* 168:173 */       rs.setRequestResult("系统异常，请稍后再试。");
/* 169:    */     }
/* 170:175 */     return JSON.toJSONString(rs);
/* 171:    */   }
/* 172:    */   
/* 173:    */   @RequestMapping({"/excelBalanceOfPayments"})
/* 174:    */   @ResponseBody
/* 175:    */   public byte[] excelBalanceOfPayments(HttpServletRequest request, HttpServletResponse response)
/* 176:    */   {
/* 177:186 */     byte[] b = null;
/* 178:    */     try
/* 179:    */     {
/* 180:188 */       String merchantCode = request.getParameter("merchantCode");
/* 181:189 */       String start = request.getParameter("startDate");
/* 182:190 */       String end = request.getParameter("endDate");
/* 183:191 */       DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
/* 184:192 */       Date startDate = null;
/* 185:193 */       Date endDate = null;
/* 186:194 */       if (StringUtils.isNotBlank(start)) {
/* 187:195 */         startDate = df.parse(start);
/* 188:    */       }
/* 189:197 */       if (StringUtils.isNotBlank(end)) {
/* 190:198 */         endDate = df.parse(end);
/* 191:    */       }
/* 192:200 */       List<Map<String, Object>> balanceList = this.merchantReportService.queryBalanceOfPayments(startDate, endDate, merchantCode);
/* 193:201 */       LinkedHashMap<String, String> fieldMap = new LinkedHashMap();
/* 194:202 */       fieldMap.put("交易流水", "tradeNo");
/* 195:203 */       fieldMap.put("消费卡号", "cardNo");
/* 196:204 */       fieldMap.put("用户", "originalPayerName");
/* 197:205 */       fieldMap.put("业务名称", "servicename");
/* 198:206 */       fieldMap.put("交易时间", "platTime");
/* 199:207 */       fieldMap.put("会计日期", "accountingdate");
/* 200:208 */       fieldMap.put("交易总金额", "paymentAmount");
/* 201:209 */       fieldMap.put("企业名称", "merchantname");
/* 202:210 */       fieldMap.put("科目", "subjectname");
/* 203:211 */       fieldMap.put("科目金额", "amount");
/* 204:    */       
/* 205:213 */       b = ExcelUtill.getXLSByteArray("收入明细报表", fieldMap, balanceList);
/* 206:    */       
/* 207:215 */       response.setHeader("Content-Disposition", "attachment;fileName=demo.csv");
/* 208:216 */       response.setHeader("Content-Transfer-Encoding", "binary");
/* 209:217 */       response.setContentType("application/vnd.ms-excel; charset=utf-8");
/* 210:    */     }
/* 211:    */     catch (Exception e)
/* 212:    */     {
/* 213:219 */       LogUtil.error("导出收入明细报表异常", e);
/* 214:    */     }
/* 215:221 */     return b;
/* 216:    */   }
/* 217:    */   
/* 218:    */   @RequestMapping(value={"/queryMerchantSubjectAcc"}, produces={"application/json;charset=UTF-8"})
/* 219:    */   @ResponseBody
/* 220:    */   public String queryMerchantSubjectAcc(HttpServletRequest request)
/* 221:    */   {
/* 222:231 */     ResponseModle rs = new ResponseModle();
/* 223:    */     try
/* 224:    */     {
/* 225:233 */       String merchantCode = request.getParameter("merchantCode");
/* 226:234 */       String subSubjectCode = request.getParameter("subSubjectCode");
/* 227:235 */       MerchantSubjectAccVO param = new MerchantSubjectAccVO();
/* 228:236 */       param.setMerchantCode(merchantCode);
/* 229:237 */       param.setSubSubjectCode(subSubjectCode);
/* 230:238 */       List<MerchantSubjectAccVO> mertchantAccountList = this.merchantReportService.queryMerchantSubjectAcc(param);
/* 231:239 */       rs.setRequestStatus("success");
/* 232:240 */       rs.setRequestResult(mertchantAccountList);
/* 233:    */     }
/* 234:    */     catch (Exception e)
/* 235:    */     {
/* 236:242 */       LogUtil.error("查询企业账户信息异常", e);
/* 237:243 */       rs.setRequestStatus("error");
/* 238:244 */       rs.setRequestResult("系统异常，请稍后再试。");
/* 239:    */     }
/* 240:246 */     return JSON.toJSONString(rs);
/* 241:    */   }
/* 242:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.financial.MerchantReportController
 * JD-Core Version:    0.7.0.1
 */